#coding:utf8
'''
Create on 2015-5-13

@author: MT
'''


def getProfile(table, **kwargs):
    """
    从内存配置表中获取一条配置
    """
    from framework.dal.gameconfig.mem_profile import MemProfileManager

    records = MemProfileManager.filter(table, **kwargs)
    if records and len(records) > 0:
        return records[0]


def getProfileList(table, order_by=None, **kwargs):
    """
    从内存配置表中获取多条配置

    :param order_by: 排序字段, 默认升序, 前缀加-为降序
    """
    from framework.dal.gameconfig.mem_profile import MemProfileManager

    if order_by:
        records = MemProfileManager.order_by(table, order_by)
        records = MemProfileManager.filter(table, data=records, **kwargs)
    else:
        records = MemProfileManager.filter(table, **kwargs)

    return records


if __name__ == "__main__":
    """
    award_list = []
    for cfg in getProfileList('TcDailySign'):
        awards = json.loads(cfg.AwardList)
        print cfg.DayId, awards
        award_list.append(awards[random.randint(0, len(awards)-1)])
    print award_list
    """
    from framework.dal.gameconfig.mem_profile import MemProfileManager
    mem_cfg = MemProfileManager
    mem_cfg.init()
    print getProfile("TcConcubineIntimateLev", Lv=66).getJson()
